﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Restaurant.Dto
@using FwProject.Core.Restaurant
@model IPagedList<RestaurantStockDto>
@{
    Layout = null;
    int SumStock = 0;
    int SumRestaurantStock = 0;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>餐厅名称</th>
                <th>期初店存</th>
                @*<th>配送店存</th>*@
                <th>实际店存</th>
                <th>餐厅联系人</th>
                <th>联系人电话</th>
                <th style="width:200px">操作</th>
                @*<th style="width:200px;">操作</th>*@
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="5">暂无数据</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    i++;
                    <tr>
                        <td>@i</td>
                        <td>@item.RestaurantName</td>
                        <td>@item.Stock</td>
                        @*<td>@item.Stock</td>*@
                        <td>@item.RestaurantStock</td>
                        <td>@item.Name</td>
                        <td>@item.Mobile</td>
                        <td>
                            <a class="btn btn-info btn-xs" href="javascript:top.window.openTab(1009,'@item.RestaurantName-配送详情','@Url.Action("RestaurantDistributionDetails",new { id=item.RestaurantId})')">配送详情</a>
                        </td>
                    </tr>
                    SumStock += item.Stock;
                    SumRestaurantStock += item.RestaurantStock;
                }
                <tr class="footer">
                    <td style="color:red">合计</td>
                    <td></td>
                    <td style="color:red">@SumStock</td>
                    @*<td style="color:red">@SumStock</td>*@
                    <td style="color:red">@SumRestaurantStock</td>
                    <td colspan="3"></td>
                </tr>
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp; 条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&RestaurantName=@(Context.Request.Query["RestaurantName"])" />
        @Html.PagedListPager(Model, page => Url.Action("StatementAccount", new { pageIdx = page, size = Context.Request.Query["size"], RestaurantName = Context.Request.Query["RestaurantName"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>